<?php
class Email extends LilcontactsAppModel {

	var $name = 'Email';
	var $actsAs = array('Containable');
	var $validate = array(
		'contact_id' => array('numeric'),
		'email' => array('email'),
		'kind' => array('alphaNumeric')
	);

	var $belongsTo = array('Lilcontacts.Contact');

	function beforeSave() {
		if (!empty($this->data['Email']['primary'])) {
			$this->updateAll(array('primary'=>0), array(
				'Email.contact_id' => $this->data['Email']['contact_id']
			));
		}
		return true;
	}
}
?>